package com.example.vhhj.controller;

import com.example.vhhj.entity.TbUser;
import com.example.vhhj.service.TbUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("user")
public class TbUserController {
    @Autowired
    private TbUserService tbUserService;

    @RequestMapping(value = "/findAll", method = RequestMethod.GET)
    public List<TbUser> findall() {
        return tbUserService.findAll();
    }

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public String add(@RequestBody TbUser user) {
        return tbUserService.add(user);
    }


    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public String updeateUser(@RequestBody TbUser user) {
        return tbUserService.updateUser(user);
    }

    @RequestMapping(value = "/del", method = RequestMethod.GET)
    public String delUser(@RequestBody int id) {
        return tbUserService.delUser(id);
    }

    @RequestMapping(value = "/queryByName", method = RequestMethod.POST)
    public List<TbUser> queryByName(@RequestBody TbUser user) {
        return tbUserService.queryByName(user);
    }

    @RequestMapping(value = "/queryLikeName", method = RequestMethod.POST)
    public List<TbUser> queryLikeName(@RequestBody TbUser user) {
        return tbUserService.queryLikeName(user);
    }

    @RequestMapping(value = "/queryByTiaojian", method = RequestMethod.POST)
    public List<TbUser> queryByTiaojian(@RequestBody TbUser user) {
        return tbUserService.queryByTiaojian(user);
    }
}


























